package com.iqismart.shorturl.config;

import com.iqismart.shorturl.intercept.RedirectInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description
 * @Auther sty
 * @createTime 2019-10-24 12:32
 */
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    @Bean
    public RedirectInterceptor getRedirectInterceptor(){
        final RedirectInterceptor redirectInterceptor = new RedirectInterceptor();
        redirectInterceptor.webSite = getWebsite();
        return redirectInterceptor;
    }

    @Bean
    public WebSite getWebsite(){
        return new WebSite();
    }



    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getRedirectInterceptor()).addPathPatterns("/**");
    }

}
